package cn.edu.scau.dao;

import cn.edu.scau.entity.NursingContent;

import java.util.List;

import org.apache.ibatis.annotations.CacheNamespace;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.InsertProvider;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.SelectProvider;
import org.apache.ibatis.annotations.Update;
import org.apache.ibatis.annotations.UpdateProvider;
import org.apache.ibatis.type.JdbcType;
import org.springframework.data.repository.query.Param;

@Mapper
@CacheNamespace
public interface NursingContentMapper {
    @Delete({
        "delete from nursingcontent",
        "where nursingContentID = #{nursingcontentid,jdbcType=INTEGER}"
    })
    int deleteByPrimaryKey(Integer nursingcontentid);

    @Insert({
        "insert into nursingcontent (nursingContentID, nursingContentProjectName, ",
        "nursingContentPrice, nursingContentDescription, ",
        "nursingContentStatus)",
        "values (#{nursingcontentid,jdbcType=INTEGER}, #{nursingcontentprojectname,jdbcType=VARCHAR}, ",
        "#{nursingcontentprice,jdbcType=DECIMAL}, #{nursingcontentdescription,jdbcType=VARCHAR}, ",
        "#{nursingcontentstatus,jdbcType=BIT})"
    })
    int insert(NursingContent record);

    @InsertProvider(type=NursingContentSqlProvider.class, method="insertSelective")
    int insertSelective(NursingContent record);

    @Select({
        "select",
        "nursingContentID, nursingContentProjectName, nursingContentPrice, nursingContentDescription, ",
        "nursingContentStatus",
        "from nursingcontent",
        "where nursingContentID = #{nursingcontentid,jdbcType=INTEGER}"
    })
    @Results({
        @Result(column="nursingContentID", property="nursingcontentid", jdbcType=JdbcType.INTEGER, id=true),
        @Result(column="nursingContentProjectName", property="nursingcontentprojectname", jdbcType=JdbcType.VARCHAR),
        @Result(column="nursingContentPrice", property="nursingcontentprice", jdbcType=JdbcType.DECIMAL),
        @Result(column="nursingContentDescription", property="nursingcontentdescription", jdbcType=JdbcType.VARCHAR),
        @Result(column="nursingContentStatus", property="nursingcontentstatus", jdbcType=JdbcType.BIT)
    })
    NursingContent selectByPrimaryKey(Integer nursingcontentid);
    
	/**
	  * 查询所有护理内容信息 
	 * @return
	 */
	@Select({ "select", "nursingContentID, nursingContentProjectName, nursingContentPrice, nursingContentDescription, nursingContentStatus", "from nursingcontent" })
	List<NursingContent> selectAll();


	/**
	 * 根据护理项目名称模糊查询
	 * @param nursingcontentprojectname
	 * @return
	 */
	@SelectProvider(type = NursingContentSqlProvider.class,method = "findByNursingcontentprojectname")
	List<NursingContent> findByNursingcontentprojectname(@Param("nursingcontentprojectname")String nursingcontentprojectname);

    @UpdateProvider(type=NursingContentSqlProvider.class, method="updateByPrimaryKeySelective")
    int updateByPrimaryKeySelective(NursingContent record);

    @Update({
        "update nursingcontent",
        "set nursingContentProjectName = #{nursingcontentprojectname,jdbcType=VARCHAR},",
          "nursingContentPrice = #{nursingcontentprice,jdbcType=DECIMAL},",
          "nursingContentDescription = #{nursingcontentdescription,jdbcType=VARCHAR},",
          "nursingContentStatus = #{nursingcontentstatus,jdbcType=BIT}",
        "where nursingContentID = #{nursingcontentid,jdbcType=INTEGER}"
    })
    int updateByPrimaryKey(NursingContent record);
}